home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////
- //
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and
- // distribute this file in accordance with the terms
- // of the Adobe license agreement accompanying it.
- // If you have received this file from a source
- // other than Adobe, then your use, modification,
- // or distribution of it requires the prior
- // written permission of Adobe.
- //
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- //
- // Create Objects.js
- //
- // DESCRIPTION
- //
- // This script opens a new composition, creates different object in
- // that composition using the createobject/convertType methods. Also
- // shows how to set background gradient to the composition and single
- // colors to the object.
- //
- // HOW TO USE
- //
- // Select Automation > Run Automation Scripts > Create Objects.js
- // Note: Keep Console window open to see the description of objects as
- // they get created.
- //
- //////////////////////////////////////////////////
-
-
- // Main Code [Execution of script begins here]
-
- if(!(comp = application.currentComposition)){
- // if no composition open
- // opens a new composition
- comp = application.newComposition();
- Console.show();
- Console.write("New Composition opened\n");
- }
-
- createobject(comp);// Calls function createobject
-
- // Add your own functions here
-
- //////////////////////////////////////////////////
- // createobject:
- //
- // Demonstrates how user can automatically create object on the composition.
- // Not only that the object can be changed to desired shapes - ellipse, polygon etc.
- // and placed on desired location on the composition. Also shows how different
- // color/colorGradient can be given to the object/background. The file is then saved
- // with a new filename at a desired location on your computer.
- //
- // comp: The currently open and active file/composition.
- //////////////////////////////////////////////////
-
- function createobject(comp)
- {
- // Setting the background color of the composition to a linear gradient
- comp.backgroundColorGradient.type = LMGradientType.linear;
-
- // Setting the start colors of the linear gradient
- comp.backgroundColorGradient.startColor.red = 255;
- comp.backgroundColorGradient.startColor.green = 250;
- comp.backgroundColorGradient.startColor.blue = 215;
-
- // Setting end colors of the linear gradient
- comp.backgroundColorGradient.endColor.red = 135;
- comp.backgroundColorGradient.endColor.green = 245;
- comp.backgroundColorGradient.endColor.blue = 190;
-
- // Creates a rectangle by default on the Composition at coordinates (75, 75)
- // and object's index is 0 i.e.it is the first object in the composition.
- var object1 = comp.createObject(LMObjectType.geometric, 75, 75, 0);
- Console.show();
- Console.write("Geometric object 1 initially created is " + object1 + "\n");
-
- // Setting opacity Gradient for the object of type burst and angle 90 degree
- object1.layers[0].opacityGradient.type = LMGradientType.doubleBurst;
- object1.layers[0].opacityGradient.angle = 90;
-
- // Setting only start color for the object.
- // This is same as setting a single color for object without gradient.
- object1.layers[0].colorGradient.startColor.red = 0;
- object1.layers[0].colorGradient.startColor.green = 150;
- object1.layers[0].colorGradient.startColor.blue = 165;
-
- // Create aniother object at (180, 180) at object index 1 in the Composition.
- var object2 = comp.createObject(LMObjectType.geometric, 180, 180, 1);
- Console.write("Geometric object 2 initially created is " + object2 + "\n");
-
- // Convert object2 to path object
- object2 = object2.convertType(LMGeometricType.path);
- Console.write("Geometric object 2 converted to: " + object2 + "\n");
-
- // Change the stroke type to outline for object2
- object2.stroke.type = LMStrokeType.outline;
-
- // Object size can be changed - to 50,50. Initially object is created with default size
- // 100,100.
- object2.size.x = 50;
- object2.size.y = 50;
-
- // Note: Path object have paths (at least one).
- // Paths have knots (at least one).
- // When you create a path the coordinates you are giving specify the position of the
- // first knot on the path. To make connected dots you must add additional knots to
- // the same path.
- // All knots on a same path are relative to the anchor point of the object.
-
- var thePath = object2.addPath(50, 0, 1)
- // Creates a path and places it's first knot at (50, 0) relative to the anchor
- // point of the object.
-
- // Add knots to the path at different positions, relative to anchor point of the object.
- thePath.addKnot(0, 50, 1); // Index of the knot at (0, 50) in the array of knots is 1.
- thePath.addKnot(-50, 0, 2); // Index of the knot at (-50, 0) in the array of knots is 2.
- thePath.addKnot(0, -50, 3); // Index of the knot at (0, -50) in the array of knots is 3.
- thePath.closed = true; // Closing the path connects the first and last knot.
-
- // You close a path when you wan to connect two points which are already knots on the path.
-
- // Create aniother object at (275, 275) and object index 2
- var object3 = comp.createObject(LMObjectType.geometric, 275, 275, 2);// Create an object
- Console.write("Geometric object 3 initially created is " + object3 + "\n");
-
- // Converts object3 to polygon
- object3 = object3.convertType(LMGeometricType.polygon);
-
- // Number of sides of the polygon object can be set using sides.
- object3.sides = 6;
- Console.write("Geometric object 3 converted to: " + object3 + "\n");
-
- // Saves the composition file under the default/root directory with the given name
- // The second boolean arguement checks whether a file by that name already
- // exists and if false does not overwrite it else overwrites.
-
- // The file path notation is the URI notation. Two consecutive slashes means the
- // default volume. On a Macintosh it is the volume name and on Windows it is the
- // drive name.
- comp.saveComposition("//comp.liv", false);
-
- return;
- }